package com.topNews.base.core.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public abstract class BaseAction extends Action {

	public static Log logger = LogFactory.getLog(BaseAction.class);

	public static final String SUCCESS = "success";

	public static final String FAILED = "failed";

	public static final String INPUT = "input";

	@Override
	public final ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		
		String className = getClass().getName();
		
		logger.info(className + " execute time by "
				+ System.currentTimeMillis());

		ActionForward actionForward = process(mapping, form, request, response);

		logger.info(className + " executed time by "
				+ System.currentTimeMillis());

		return actionForward;
	}

	protected abstract ActionForward process(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception;
}
